<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var str = 'asdfssaaasasasasaa';
    var json = {};
    for (var i = 0; i < str.length; i++) {
      if (!json[str.charAt(i)]) {
        json[str.charAt(i)] = 1;
      } else {
        json[str.charAt(i)]++;
      }
    };
    var iMax = 0;
    var iIndex = '';
    for (var i in json) {
      if (json[i] > iMax) {
        iMax = json[i];
        iIndex = i;
      }
    }
    alert('出现次数最多的是:' + iIndex + '出现' + iMax + '次');
  </script>
</body>

</html>